import * as CryptoJS from 'crypto-js'
import { userStore } from '@/store/user.store'

/**
 * 数据加密
 * @param data
 * @param publickey
 * @returns
 */
export const encrypt = (data: string, publickey: string): string => {
  return CryptoJS.AES.encrypt(data, publickey).toString()
}

/**
 * 退出登录
 */
export const handleSignout = () => {
  userStore().clearProfile()
  window.localStorage.clear()
  location.replace(`/signin?redirect_url=${encodeURIComponent(location.href)}`)
}
